#include<iostream>
using namespace std;
#include<iomanip>
#include<cmath>

#include"library.h"

double PartGauLegInt( int m, double a, double b, double (*func)(double), int n ){

	double h = (b-a)/m;
	double y = 0;
	for(int i=0;i<m;i++)
		y += GauLegInt( a + i*h, a + (i+1)*h, func, n );
	return y;
}

double f( double x ){
	return sin( x ) + sin(4*x) + sin(8*x);
}

int main(){

	cout<<" 4 rank-5 : "<< setprecision(15) << PartGauLegInt( 4, 0, M_PI, f, 5 )<<endl;
	cout<<" rank-20 : "<< setprecision(15) << PartGauLegInt( 1, 0, M_PI, f, 20 )<<endl;

	return 0;
}
